package com.saltedfish.tool.ui.flag.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.saltedfish.tool.R;
import com.saltedfish.tool.model.SmallTable;
import com.saltedfish.tool.model.WeekInfo;

import java.util.ArrayList;
import java.util.List;

import cn.droidlover.xdroidmvp.base.SimpleListener;


public class WeekShowAdapter extends BaseQuickAdapter<SmallTable, BaseViewHolder> {

    private SimpleListener listener;

    private Context mContext;

    private int selectPosition = 0;

    private List<WeekInfo> selectList;

    private List<SmallTable> smallTableList;


    private WeekColorAdapter flagAdapter;


    public void setListener(SimpleListener listener) {
        this.listener = listener;
    }

    public WeekShowAdapter(List<SmallTable> data, Context context) {
        super(R.layout.item_week_buttom, data);
        this.mContext = context;
        this.smallTableList = data;
        initData();
    }


    private void initData() {
        selectList = new ArrayList<>();
        selectList.add(new WeekInfo("周一",false));
        selectList.add(new WeekInfo("周二",false));
        selectList.add(new WeekInfo("周三",false));
        selectList.add(new WeekInfo("周四",false));
        selectList.add(new WeekInfo("周五",false));
        selectList.add(new WeekInfo("周六",false));
        selectList.add(new WeekInfo("周日",false));
    }


    @Override
    protected void convert(BaseViewHolder helper, final SmallTable smallTable) {
        RecyclerView mRecyclerView = helper.getView(R.id.mRecyclerView);
        TextView tvDate = helper.getView(R.id.tvDate);
        TextView tvTitle = helper.getView(R.id.tvTitle);

        tvDate.setText(smallTable.repeatTime);
        tvTitle.setText(smallTable.title);
        int position = helper.getAdapterPosition();

        flagAdapter = new WeekColorAdapter(selectList,smallTable.repeatDay,mContext);
        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.setLayoutManager(new GridLayoutManager(mContext,7));
        mRecyclerView.setAdapter(flagAdapter);

//        viewSelect.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                if(listener !=null){
//                    listener.onClick(position);
//                   // setSelectPosition(position);
//                    notifyDataSetChanged();
//                }
//            }
//        });


    }


}
